// koa1.0  generator
// koa2.0  async await

// generator + co === async await
let fs = require("fs/promises");
async function read() {
  try {
    // 这个代码肯定是异步的，但是写的像同步代码
    let url = await fs.readFile("./fileUrl1.txt", "utf8");
    let name = await fs.readFile(url, "utf8");
    return name;
  } catch (e) {
    console.log(e, 55); // it.throw
    throw e;
  }
}
// 省略了co 语法糖
read()
  .then((data) => {
    console.log(data);
  })
  .catch((e) => {
    console.log(e, 21);
  });

// 回调 + 异步（高阶函数） + promise来简化回调 + generator + co + async + await
